package com.han.shadow.customerapp.adapter;

import android.content.Context;
import android.graphics.Bitmap;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.han.shadow.customerapp.R;
import com.han.shadow.customerapp.bean.Goods;

import org.w3c.dom.Text;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by ACE on 2016/4/20 0020.
 */
public class MyGoodsesAdapter extends BaseAdapter {

    private List<Goods> goodses;
    private LayoutInflater inflater;
    private Context context;
    private List<ImageView> imageViews = new ArrayList<>();


    private TextView textName = null;
    private TextView textPrice = null;
    private TextView textSalesVolume = null;
    private TextView textSellTime = null;
    private TextView textState = null;



    public MyGoodsesAdapter(List<Goods> goodses, LayoutInflater inflater, Context context){
        this.goodses = goodses;
        this.inflater = inflater;
        this.context = context;
    }


    @Override
    public int getCount() {
        return goodses.size();
    }

    @Override
    public Object getItem(int position) {
        return goodses.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
}

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {

        convertView = inflater.inflate(R.layout.activity_goodses_style,null);
        final Goods goods = goodses.get(position);

        textName = (TextView)convertView.findViewById(R.id.text_gs_name);
        textPrice = (TextView)convertView.findViewById(R.id.text_gs_price);
        textSalesVolume = (TextView)convertView.findViewById(R.id.text_gs_salesvolume);
        textSellTime = (TextView)convertView.findViewById(R.id.text_gs_selltime);
        textState = (TextView)convertView.findViewById(R.id.text_gs_state);
       // ImageView image = (ImageView)convertView.findViewById(R.id.image_gs_goods);


        textName.setText(goods.getName());
        textPrice.setText((float)(goods.getPrice()/10)+"元/份");
        textSalesVolume.setText(goods.getSalesVolume() + "份");
        textSellTime.setText(goods.getSelltime());
        if(goods.getStatus() == 1){
            textState.setText("上架");
        }else{
            textState.setText("上架");
        }
        //imageViews.add(image);



        return convertView;
    }

//    public List<ImageView> getImageViews(){
//        return imageViews;
//    }
//
//    public void update(List<List<Bitmap>> bitmaps){
//        //List<ImageView> imagesViews = adapter.getImageViews();
//        for(int i = 0; i < bitmaps.size(); i++){
//            imageViews.get(i).setImageBitmap(bitmaps.get(i).get(0));
//        }
//
//
//        notifyDataSetChanged();
//    }


}
